package com.qf.service.caiwu_service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qf.bean.Debt;
import com.qf.bean.DebtOrder;
import com.qf.dao.caiwu_dao.DebtOrderMapper;
import com.qf.service.caiwu_service.DebtOrderService;
import com.qf.utils.RandomUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 2019/12/10 0010
 * Author->DT
 * sassspringboot
 * 行到水穷处 坐看云起时
 * 模块：
 */
@Service
public class DebtOrderServiceImpl implements DebtOrderService {
    @Resource
    private DebtOrderMapper debtOrderMapper;
    @Override
    public PageInfo<DebtOrder> findDebtOrderListByLimit(Map map) {
        //开启分页
        PageHelper.startPage((int)map.get("index"),(int)map.get("page"));
        //查询欠款订单信息列表
        List<DebtOrder> list=debtOrderMapper.findDeptOrderList(map);
        //封装PageInfo
        PageInfo<DebtOrder> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    //查询当前客户历史欠款单
    @Override
    public List<DebtOrder> selectOweDebtOrderList(Integer did) {
        return debtOrderMapper.selectOweDebtOrderList(did);
    }

    //添加收款订单表
    @Override
    public int addRefundOrder(DebtOrder debtOrder) {
        //自动生成单据编号
        debtOrder.setReceiptNum(RandomUtil.random());
        //设置经办人
        debtOrder.setOperator("阿杜");
        //执行添加
        int i = debtOrderMapper.insertSelective(debtOrder);
        return i;
    }
}
